package com.qys.livesMall.shop.controller.app;


import com.qys.livesMall.common.result.R;
import com.qys.livesMall.shop.modal.dto.shop.ShopScoreDTO;
import com.qys.livesMall.shop.modal.vo.ShopScoreVO;
import com.qys.livesMall.shop.service.ShopScoreService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 店铺评分表(ShopScore)表控制层
 *
 * @author makejava
 * @since 2023-08-24 15:54:04
 */
@RestController
@RequestMapping("/app/shopScore")
@RequiredArgsConstructor
@Tag(name = "app-店铺评分", description = "app-店铺评分")
public class ShopScoreController {
  
    private final ShopScoreService shopScoreService;


    @PostMapping("/setMark")
    @Operation(summary = "对店铺评分")
    public R<?> setMark(@RequestBody @Validated ShopScoreDTO dto) {
        try {
            shopScoreService.setMark(dto);
        } catch (Exception e) {
            return R.fail(e.getMessage());
        }
        return R.ok();
    }



    @GetMapping("/queryMark/{shopId}")
    @Operation(summary = "获取店铺评分")
    public R<ShopScoreVO> queryMark(@PathVariable Long shopId) {
        return R.ok(shopScoreService.queryMark(shopId));
    }

}

